package com.ruoyi.demo.database;

import com.zhr.jdbc.WebJdbcClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author LIUJUN
 */
@Data
@Component
@ConfigurationProperties(prefix = "dbserver")
public class WebJdbcFactory {
    private String baseUrl;
    private String defaultDataSourceName;

    public WebJdbcFactory() {
        this.defaultDataSourceName = "";
    }

    public WebJdbcClient buildNewClient() {
        return buildNewClient(this.defaultDataSourceName);
    }

    public WebJdbcClient buildNewClient(String ds) {
        return new WebJdbcClient(ds, this.baseUrl);
    }
}
